package com.zlll.winner.controller;

import com.alibaba.fastjson.JSONObject;
import com.zlll.winner.business.model.media.MediaVideoList;
import com.zlll.winner.business.service.media.IMediaVideoListService;
import com.zlll.winner.common.BaseController;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("api/media/video/list")
@RestController
public class MediaVideoListController extends BaseController {

    @Reference(version = "${dubbo.consumer.version}")
    private IMediaVideoListService mediaVideoListService;

    /**
     * 前端获取所以的视频列表
     * @param data
     * @return
     */
    @PostMapping("/search")
    public Object search(@RequestBody JSONObject data){
        Integer pageSize = data.getInteger("pageSize") == null ? 10 : data.getInteger("pageSize");
        Integer pageNo = data.getInteger("pageNo") == null ? 1 : data.getInteger("pageNo");
        data.put("status", 1);
        data.put("pageNo",pageNo);
        data.put("pageSize",pageSize);
        return mediaVideoListService.fetchVideoListPage(data);
    }

    /**
     * 获取首页的视频接口
     * @return
     */
    @PostMapping("/index")
    public MediaVideoList index(){
        return mediaVideoListService.fetchVideoLast();
    }
}
